dir=$(dirname $0)
cd $dir && cd ..

OUTPUT="output"
rm -rf $OUTPUT
npm run build

if [ ! -d $OUTPUT ]
then
    exit 0
fi

cd $OUTPUT

cp -rf ../lib .
cp -rf ../package.json ./
mkdir node_modules
cp -rf ../node_modules/f2e-server3 ./node_modules/
cp -rf ../node_modules/f2e-middle-rbac ./node_modules/

if [ -d "../node_modules/uWebSockets.js" ]
then
    cp -rf ../node_modules/uWebSockets.js/ ./node_modules/
    node -e "import('../script/uws_shaking.mjs').then(m => m.only('linux_x64_115'))"
fi

